﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using OpenMms.Common.Auth;
using OpenMms.Domain.Interface.User;
using Microsoft.AspNetCore.Mvc;
using OpenMms.Common.Log;

namespace OpenMms.MVC.Areas.User.Controllers
{
    /// <summary>
    /// 会员首页
    /// </summary>
    [Area("User")]
    public class HomeController : BaseController
    {
        #region 注入
        private IHomeService _service;
        public HomeController(IAuth auth, IHomeService service) : base(auth) => this._service = service;
        #endregion

        #region 首页
        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        //[LoginFilter]
        public async Task<IActionResult> Index()
        {
            var sessioninfo = base._auth.GetCurrentUser();
            //用户信息
            var userinfo = await _service.GetInfo(sessioninfo.Account);
            //log.Info(userinfo);
            //公告列表
            ViewBag.Notice = await _service.GetNotices();

            return View(userinfo);
        }
        #endregion
    }
}